<template>
	<div class="app-container">
		<!-- 搜索 orderNumber customerName customerPhone address status-->
		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
			<el-form-item label="订单号" prop="orderNumber">
				<el-input v-model="queryParams.orderNumber" placeholder="请输入订单号" clearable style="width: 240px"
					@keyup.enter.native="handleQuery" />
			</el-form-item>

			<el-form-item label="客户名称" prop="customerName">
				<el-input v-model="queryParams.customerName" placeholder="请输入客户名称" clearable style="width: 240px"
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<el-form-item label="是否加急">
				<el-select v-model="queryParams.priority" placeholder="请选择">
					<el-option v-for="item in dict.type.sys_isno" :key="item.value" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="是否生产">
				<el-select v-model="queryParams.produce" placeholder="请选择">
					<el-option v-for="item in dict.type.sys_isno" :key="item.value" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="是否月结">
				<el-select v-model="queryParams.billMonth" placeholder="请选择">
					<el-option v-for="item in dict.type.sys_costomer_type" :key="item.value" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="订单来源">
				<el-select v-model="queryParams.orderSource" placeholder="请选择">
					<el-option v-for="item in dict.type.sys_order_type" :key="item.id" :label="item.label"
						:value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="客户电话" prop="customerPhone">
				<el-input v-model="queryParams.customerPhone" placeholder="请输入客户手机" clearable style="width: 240px"
					@keyup.enter.native="handleQuery" />
			</el-form-item>
			<!-- <el-form-item label="地址" prop="address">
				<el-input v-model="queryParams.address" placeholder="请输入客户地址" clearable style="width: 240px"
					@keyup.enter.native="handleQuery" />
			</el-form-item> -->
			<el-form-item label="订单状态" prop="status">
				<el-select v-model="queryParams.status" placeholder="请选择">
					<el-option v-for="item in slist" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="客服" prop="createUserId">
				<el-select v-model="queryParams.createUserId" placeholder="请选择">
					<el-option v-for="item in userList" :key="item.value" :label="item.label" :value="item.value">
					</el-option>
				</el-select>
			</el-form-item>
			<el-form-item label="创建时间" prop="dateRange">
				<el-date-picker v-model="dateRange" type="daterange" range-separator="至" start-placeholder="开始日期"
					style="width: 240px" value-format="yyyy-MM-dd" end-placeholder="结束日期" @change="timeChange">
				</el-date-picker>
			</el-form-item>
			<el-form-item label="发货时间" prop="dateRange">
				<el-date-picker v-model="dateRange2" type="daterange" range-separator="至" start-placeholder="开始日期"
					style="width: 240px" value-format="yyyy-MM-dd" end-placeholder="结束日期" @change="timeChange2">
				</el-date-picker>
			</el-form-item>
			<el-form-item label="完成时间" prop="dateRange">
				<el-date-picker v-model="dateRange1" type="daterange" range-separator="至" start-placeholder="开始日期"
					style="width: 240px" value-format="yyyy-MM-dd" end-placeholder="结束日期" @change="timeChange1">
				</el-date-picker>
			</el-form-item>
			<el-form-item label="状态过滤" prop="filterCancel">
				<el-checkbox :true-label="1" :false-label="0" v-model="queryParams.filterCancel"
					label="过滤已取消订单"></el-checkbox>
			</el-form-item>
			<el-form-item label="订单备注" prop="remark">
				<el-input v-model.trim="queryParams.remark" placeholder="请输入订单备注" clearable style="width: 240px"
					@keyup.enter.native="handleQuery" />
			</el-form-item>



			<!-- 防止仅有一个输入框时光标在那一个输入框里时按回车出现“正在加载系统资源，请耐心等待” -->
			<input hidden />
			<el-form-item>
				<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
				<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>

		<!-- 工具栏 -->
		<el-row :gutter="10" class="mb8">
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
					v-hasPermi="['orders:add']">新增</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-s-order" size="mini" :disabled="single"
					@click="handleOrder" v-hasPermi="['orders:preview:scheduling']">订单排产</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport"
					v-hasPermi="['orders:export']">导出</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleEyes"
					v-hasPermi="['orders:statistics:province:ratio']">数据统计</el-button>
			</el-col>

			<el-col :span="1.5" style="margin-left: 50px;">
				<el-tag>合计件数：{{ product_count_sum }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>订单应收：{{ amountSum2 }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>订单实收：{{ amountSum1 }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>合计应收：{{ hjys }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>合计实收：{{ hjss }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>运费应收：{{ amountSum4 }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>运费实收：{{ amountSum5 }}</el-tag>
			</el-col>
			<el-col :span="1.5">
				<el-tag>理赔金额统计：{{ amountSum3 }}</el-tag>
			</el-col>
			<right-toolbar :showSearch.sync="showSearch" @queryTable="getDataList"></right-toolbar>
		</el-row>
		<!-- 表格 -->
		<el-table :cell-style="tableRowClassName" v-loading="loading" :data="dataList"
			@selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55" align="center" />
			<el-table-column label="ID" prop="id" width="60" />
			<el-table-column label="订单号" prop="orderNumber" width="120" />
			<el-table-column label="订单备注" prop="remark" width="150" show-overflow-tooltip />
			<!-- 待确认10 待排产20 待生产30 生产中40 待发货50 待收货61 待取货62 已收货71 已取货72 已完成90 -->
			<el-table-column label="订单状态">
				<template slot-scope="scope">
					<el-tag size="medium" type="success" v-if="scope.row.status == '90'">已完成</el-tag>
					<el-tag size="medium" type="info" v-if="scope.row.status == '61'">待收货</el-tag>
					<el-tag size="medium" type="info" v-if="scope.row.status == '62'">待取货</el-tag>
					<el-tag size="medium" type="warning" v-if="scope.row.status == '71'">已收货</el-tag>
					<el-tag size="medium" type="warning" v-if="scope.row.status == '72'">已取货</el-tag>
					<el-tag size="medium" v-if="scope.row.status == '10'">待确认</el-tag>
					<el-tag size="medium" v-if="scope.row.status == '20'">待排产</el-tag>
					<el-tag size="medium" type="success" v-if="scope.row.status == '30'">待生产</el-tag>
					<el-tag size="medium" type="success" v-if="scope.row.status == '40'">生产中</el-tag>
					<el-tag size="medium" type="success" v-if="scope.row.status == '50'">待发货</el-tag>
					<el-tag size="medium" type="danger" v-if="scope.row.status == '00'">已取消</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="工序状态" width="180">
				<template slot-scope="scope">
					<el-tag size="medium" v-if="scope.row.status == '30' && scope.row.stepStatus1 == 0">待生产</el-tag>
					<el-tag size="medium"
						v-if="scope.row.status == '40' && scope.row.stepStatus1 == 1 && scope.row.stepStatus2 == 0">工序一：型材切割已完成</el-tag>
					<el-tag size="medium"
						v-if="scope.row.status == '40' && scope.row.stepStatus2 == 1 && scope.row.stepStatus3 == 0">工序二：百叶制作已完成</el-tag>
					<el-tag size="medium"
						v-if="scope.row.status == '40' && scope.row.stepStatus3 == 1 && scope.row.stepStatus4 == 0">工序三：玻璃制作已完成</el-tag>
					<el-tag size="medium"
						v-if="scope.row.status == '40' && scope.row.stepStatus4 == 1 && scope.row.stepStatus5 == 0">工序四：成品组装已完成</el-tag>
					<el-tag size="medium"
						v-if="scope.row.status == '50' && scope.row.stepStatus5 == 1">工序五：包装检验已完成</el-tag>
				</template>
			</el-table-column>
			<el-table-column label="客服" width="120" prop="createUserName" />
			<el-table-column label="客户名称" prop="customerName" width="100" show-overflow-tooltip />
			<el-table-column label="客户电话" prop="customerPhone" width="120" />
			<el-table-column label="订单应收" prop="amountReceivable" width="110" />
			<el-table-column label="订单实收" prop="amountReceipts" width="110" />
			<el-table-column label="合计件数" prop="amountReceipts" width="80">
				<template slot-scope="scope">
					<div>{{ scope.row.productCount }}
					</div>
				</template>
			</el-table-column>
			<el-table-column label="合计应收" width="110">
				<template slot-scope="scope">
					<span>{{ scope.row.amountReceivable + scope.row.amountDelivery }}</span>
				</template>
			</el-table-column>
			<el-table-column label="合计实收" width="110">
				<template slot-scope="scope">
					<span>{{ scope.row.amountReceipts + scope.row.amountDeliveryTrue }}</span>
				</template>
			</el-table-column>
			<el-table-column label="运费应收" prop="amountDelivery" width="80" />
			<el-table-column label="运费实收" prop="amountDeliveryTrue" width="80" />
			<el-table-column label="订单来源" prop="orderSource" width="100" />
			<el-table-column label="是/否月结" prop="billMonth" width="100">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.sys_costomer_type" :value="scope.row.billMonth" />
				</template>
			</el-table-column>
			<el-table-column label="是否生产" prop="produce" width="100">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.sys_isno" :value="scope.row.produce" />
				</template>
			</el-table-column>
			<el-table-column label="是否加急" prop="priority" width="100">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.sys_isno" :value="scope.row.priority" />
				</template>
			</el-table-column>
			<el-table-column label="创建时间" prop="createTime" width="150" />
			<el-table-column label="发货时间" prop="deliveryTime" width="150" />
			<el-table-column label="完成时间" prop="finishTime" width="150" />
			<el-table-column label="交期" prop="deliveryDay" width="80" />
			<el-table-column label="物流平台" prop="deliveryName" width="80" />
			<el-table-column label="物流单号" prop="deliveryNumber" width="120" show-overflow-tooltip />
			<el-table-column label="理赔金额" prop="amountCompensate" width="80" />
			<el-table-column label="物流方式">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.self_delivery_mode" :value="scope.row.deliveryMode" />
				</template>
			</el-table-column>
			<el-table-column label="收件人" prop="deliveryPerson" width="100" />
			<el-table-column label="收件电话" prop="deliveryPhone" width="120" />
			<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="260">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-view" v-hasPermi="['orders:info']"
						@click="handleDetail(scope.row)">详情</el-button>
					<!-- 修改物流 管理员 超级管理员  订单在待收货时可以修改 -->
					<el-button v-if="scope.row.status == '61'" size="mini" type="text" @click="editDelivery(scope.row)"
						v-hasPermi="['orders:delivery:edit']">修改物流</el-button>
					<el-button size="mini" type="text" @click="shconfirm(scope.row)"
						v-hasPermi="['orders:after:sales']">售后</el-button>
					<el-button size="mini" type="text" @click="handleUpdate(scope.row)"
						v-if="scope.row.status == '10' || scope.row.status == '20'"
						v-hasPermi="['orders:edit']">修改</el-button>
					<el-button size="mini" type="text" icon="el-icon-delete" @click="handleDel(scope.row)"
						v-if="checkPermi(['orders:remove']) && scope.row.status == '10'">删除</el-button>
					<el-button size="mini" type="text" icon="el-icon-refresh-left" @click="handleCancel(scope.row)"
						v-if="checkPermi(['orders:cancel']) && (scope.row.status == '20' || scope.row.status == '10')">取消</el-button>

					<!-- 待确认10 待排产20 待生产30 生产中40 待发货50 待收货61 待取货62 已收货 71已取货72 已完成90 -->
					<el-button size="mini" type="text" v-if="checkPermi(['orders:confirm']) && scope.row.status == '10'"
						@click="confirmDetail(scope.row)">订单确认</el-button>
					<el-button size="mini" type="text" @click="overDetail(scope.row)"
						v-if="scope.row.status == '71' || scope.row.status == '72'"
						v-hasPermi="['orders:finish']">完成</el-button>
					<el-button size="mini" type="text" @click="addPay(scope.row)"
						v-hasPermi="['orders:pay:add']">收款</el-button>
					<el-button size="mini" type="text" @click="downexportOrder(scope.row)"
						v-hasPermi="['orders:print:order']">下载订货单</el-button>
					<el-button size="mini" type="text" @click="setPrice(scope.row)"
						v-hasPermi="['orders:update:compensate']">理赔金额</el-button>
				</template>
			</el-table-column>
		</el-table>
		<!-- 分页 -->
		<pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
			:limit.sync="queryParams.pageSize" @pagination="getDataList" />
		<!-- 收款 -->
		<el-dialog title="订单收款" :visible.sync="payShow" width="700px" append-to-body>
			<el-form ref="payFormRef" :model="payData" size="medium" :rules="payrules">
				<el-form-item label="金额类型" prop="recordType">
					<el-radio-group v-model="payData.recordType" @change="paychange">
						<el-radio v-for="item in dict.type.self_order_payment_type" :key="item.id"
							:label="item.value">{{
								item.label }}</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-row :gutter="10" class="mb8">
					<div v-if="payData.recordType == '订单金额'">
						<el-col :span="1.5">
							<el-tag>订单金额应收：{{ paydataInfos.amountReceivable }}</el-tag>
						</el-col>
						<el-col :span="1.5">
							<el-tag>订单金额实收：{{ paydataInfos.amountReceipts }}</el-tag>
						</el-col>
					</div>
					<div v-if="payData.recordType == '运费金额'">
						<el-col :span="1.5">
							<el-tag>运费金额应收：{{ paydataInfos.amountDelivery }}</el-tag>
						</el-col>
						<el-col :span="1.5">
							<el-tag>运费金额实收：{{ paydataInfos.amountDeliveryTrue }}</el-tag>
						</el-col>
					</div>
				</el-row>
				<el-form-item v-if="payData.recordType == '订单金额'" label="付款方式" prop="typePayment">
					<el-radio-group v-model="payData.typePayment" @change="typePaymentChange" :disabled="isdisabled">
						<el-radio v-for="item in dict.type.self_order_pay_type" :key="item.id" :label="item.value">{{
							item.label
						}}</el-radio>
					</el-radio-group>
				</el-form-item>
				<el-form-item v-if="payData.typePayment == '02'" label="套餐" prop="packageId" label-width="50px">
					<el-select @change="pricechange" v-model="payData.packageId" placeholder="请选择套餐"
						:style="{ width: '100%' }">
						<el-option v-for="dict in packageList" :key="dict.id" :label="dict.packageTitle"
							:value="dict.id">
							<div style="display: flex;align-items: center;justify-content: space-between;">
								<div style="width: 60%;">{{ dict.packageTitle }}</div>
								<div
									style="color: #8492a6; font-size: 13px;display: flex;justify-content: space-between;">
									<div style="margin-right: 20px">套餐余额：<span style="color: #606266;">{{
										dict.amountSubRatio
									}}</span></div>
									<div>折扣比例：<span style="color: #606266;">{{ dict.ratio }}</span></div>
								</div>
							</div>
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="抵扣金额" label-width="80px" v-if="payData.typePayment == '02'">
					<el-input disabled v-model="payData.dk" placeholder="请输入金额" type="number" clearable
						:style="{ width: '100%' }">
					</el-input>
				</el-form-item>
				<el-form-item label="应付金额" label-width="80px" v-if="payData.typePayment == '02'">
					<el-input disabled v-model="payData.yf" placeholder="请输入金额" type="number" clearable
						:style="{ width: '100%' }">
					</el-input>
				</el-form-item>
				<el-form-item label="收款金额" prop="amountPayment" label-width="80px" v-if="payData.typePayment == '01'">
					<el-input :disabled="payData.typePayment == '02'" v-model="payData.amountPayment"
						placeholder="请输入金额" type="number" clearable :style="{ width: '100%' }">
					</el-input>
				</el-form-item>
				<el-form-item label="支付凭证" style="border: 1px dashed red;" @paste.native="handlePaste"
					prop="filePayment">
					<div style="color: red;">点击红色虚线区域可粘贴上传</div>
					<el-upload ref="productImage" :file-list="uploadImageList" :action="uploadAction" multiple
						list-type="picture-card" :headers="uploadHeaders" :on-remove="handleProductImageRemove"
						:on-success="handleUploadSuccess">
						<i class="el-icon-plus"></i>
					</el-upload>
				</el-form-item>

				<el-form-item label="收款日期" prop="datePaymentStr">
					<el-date-picker :clearable="false" :editable="false" value-format="yyyy-MM-dd"
						v-model="payData.datePaymentStr" type="date" placeholder="选择收款日期">
					</el-date-picker>
				</el-form-item>
				<el-form-item label="收款方式" prop="accountTypeName">
					<el-select v-model="payData.accountTypeName" placeholder="请选择收款方式" @change="paychangzhangh">
						<el-option v-for="item in dict.type.sys_price_type" :key="item.id" :label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="收款账号" prop="accountNumber">
					<el-select v-model="payData.accountNumber" placeholder="请选择收款账号">
						<el-option v-for="item in zhanghlist" :key="item.id" :label="item.accountNumber"
							:value="item.accountNumber">
						</el-option>
					</el-select>
				</el-form-item>

				<el-form-item label="备注" prop="remark" label-width="40px">
					<el-input v-model="payData.remark" placeholder="请输入备注" clearable :style="{ width: '100%' }">
					</el-input>
				</el-form-item>
			</el-form>
			<div slot="footer">
				<el-button @click="payCancel">取消</el-button>
				<el-button type="primary" @click="payConfirm">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="修改物流信息" :visible.sync="deliveryopen" width="500px" append-to-body>
			<el-form ref="deliveryFrom" :rules="rules" :model="deliveryFrom" size="medium" label-width="100px">
				<!-- <el-form-item label="快递方式" prop="deliveryMode">
					<el-radio-group v-model="deliveryFrom.deliveryMode" size="mini">
						<el-radio v-for="(item, index) in dict.type.self_delivery_mode" :key="index"
							:label="item.value">{{
								item.label }}</el-radio>
					</el-radio-group>
				</el-form-item> -->
				<el-form-item label="平台名字" prop="deliveryName" v-if="deliveryFrom.deliveryMode == 1">
					<el-select v-model="deliveryFrom.deliveryName" value-key="id" placeholder="请选择快递平台"
						@change="pestChange">
						<el-option v-for="item in wuliuList" :key="item.id" :label="item.deliveryName" :value="item">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="物流单号" prop="deliveryNumber" v-if="deliveryFrom.deliveryMode == 1">
					<el-input v-model="deliveryFrom.deliveryNumber" placeholder="请输入物流单号"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer">
				<el-button @click="payCancel">取消</el-button>
				<el-button type="primary" @click="deliveryConfirm">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog title="售后提交" :visible.sync="shopen" width="500px" append-to-body>
			<el-form ref="shfrom" :rules="shrules" :model="shfrom" size="medium" label-width="100px">
				<el-form-item label="问题类型" prop="problemType">
					<el-select v-model="shfrom.problemType" value-key="id" placeholder="请选择问题类型" @change="pestChange">
						<el-option v-for="item in dict.type.sys_aftersales_type" :key="item.id" :label="item.label"
							:value="item.value">
						</el-option>
					</el-select>
				</el-form-item>
				<el-form-item label="问题描述" prop="problemDescribe">
					<el-input type="textarea" placeholder="请输入问题描述" v-model="shfrom.problemDescribe" maxlength="500"
						show-word-limit></el-input>
				</el-form-item>
				<el-form-item label="上传文件" prop="problemImg">
					<el-upload class="upload-demo" :action="uploadAction" :file-list="fileList" :headers="uploadHeaders"
						:on-remove="handleProductImageRemove1" :on-success="handleUploadSuccess1">
						<el-button size="small" type="primary">点击上传</el-button>
					</el-upload>
				</el-form-item>
			</el-form>
			<div slot="footer">
				<el-button @click="payCancel">取消</el-button>
				<el-button type="primary" @click="shyConfirm">确定</el-button>
			</div>
		</el-dialog>
		<el-dialog class="uopen" title="生成批次预览" :visible.sync="scheduopen" width="740px" append-to-body>
			<el-row :gutter="10" class="mb8">
				<el-col :span="1.5">
					<el-button type="primary" plain icon="el-icon-edit" size="mini" @click="dialogFormVisible = true" >设置产品数量</el-button>
				</el-col>
			</el-row>
			<el-table v-loading="loading" :data="shengchanList" height="400">
				<el-table-column label="批次号" prop="batchNumber" width="160" />
				<el-table-column label="产品名称" prop="productName" width="120" show-overflow-tooltip />
				<el-table-column label="叶片类型" prop="bladeType" width="100" />
				<el-table-column label="驱动方式" prop="driveMode" width="100" />
				<el-table-column label="合计件数 " prop="productCountSum" width="100" />
				<el-table-column label="产品数量" prop="productCount" width="100" />
			</el-table>
			<div slot="footer">
				<el-button @click="payCancel">取消</el-button>
				<el-button type="primary" @click="paichanConfirm">确认排产</el-button>
			</div>
		</el-dialog>
		<el-dialog title="设置产品数量" :visible.sync="dialogFormVisible" width="400px" append-to-body>
			<el-form ref="shengchanform" :model="shengchanform" :rules="shengchanrules" size="medium"
				label-width="100px">
				<el-form-item label="产品数量" prop="num">
					<el-input v-model="shengchanform.num" type="number"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click="dialogFormVisible = false">取 消</el-button>
				<el-button type="primary" @click="shengchanConfim">重新生成预览批次</el-button>
			</div>
		</el-dialog>
		<!-- 排产 -->
		<el-dialog title="数据统计" :visible.sync="planShow" width="1200px" append-to-body>
			<div style="display: flex;align-items: center;">
				<div ref="echartsZx1" style="width:50%; height: 40vh"></div>
				<div ref="echartsZx2" style="width:50%; height: 40vh"></div>
			</div>
			<div slot="footer">
				<el-button @click="planCancel">取消</el-button>
			</div>
		</el-dialog>
		<!-- 排产 -->
		<el-dialog title="设置理赔金额" :visible.sync="priceShow" width="400px" append-to-body>
			<el-form ref="priceForm" :model="priceForm" :rules="priceFormles" size="medium" label-width="100px">
				<el-form-item label="理赔金额" prop="amountCompensate">
					<el-input v-model="priceForm.amountCompensate" type="number"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer">
				<el-button @click="priceShow = false">取消</el-button>
				<el-button type="primary" @click="priceFormConfim">提交</el-button>
			</div>
		</el-dialog>
	</div>
</template>
<script>

// 客户管理
import {
	postOrdersList,
	postOrdersConfirm,
	postOrdersScheduling,
	postOrdersFinish,
	postOrdersPayAdd,
	postOrdersCancel,
	getsslist,
	postOrdersPaySum,
	exportOrder,
	postOrdersRemove,
	postDditDelivery,
	postAfter,
	scheduWarn,
	scheduList,
	scheduYes,
	getzhanghList,
	getCheckPay,
	getEcharts,
	setPricePost
} from '@/api/order/order'
import { validMobile } from '@/utils/validate'
import { postUserGroupList, getUserListRole } from '@/api/group'
import { postDeliveryList } from '@/api/delivery'
import { getToken } from '@/utils/auth'
import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
import * as echarts from 'echarts';
export default {
	name: 'CustomerList',
	dicts: [
		'self_delivery_mode',
		'sys_isno',
		'sys_aftersales_type',
		'sys_order_type',
		'self_order_payment_type',
		'sys_price_type',
		'self_order_pay_type',
		'sys_costomer_type'
	],
	data() {
		// 验证添加或编辑弹框里的分组成员
		const validateMobile = (rule, value, callback) => {
			if (!validMobile(value)) {
				callback(new Error('请输入正确的手机号码'))
			} else {
				callback()
			}
		}
		return {
			zhanghlist: [],
			pcType: 0,
			dateRange: [],
			dateRange1: [],
			dateRange2: [],
			slist: [],
			planShow: false,
			payShow: false,
			payData: {
				orderId: '',
				recordType: '',
				typePayment: '',
				packageId: '',
				amountPayment: '',
				filePayment: '',
				datePaymentStr: '',
				accountTypeName: '',
				accountNumber: '',
				remark: '',
			},
			packageList: [],
			paydataInfos: {},
			payrules: {
				recordType: [{ required: true, message: '请选择金额类型', trigger: 'change' }],
				typePayment: [{ required: true, message: '请选择付款方式', trigger: 'change' }],
				packageId: [{ required: true, message: '请选择套餐', trigger: 'blur' }],
				amountPayment: [{ required: true, message: '请输入金额', trigger: 'blur' }],
				datePaymentStr: [{ required: true, message: '选择收款日期', trigger: 'blur' }],
				accountTypeName: [{ required: true, message: '请选择收款方式', trigger: 'blur' }],
				accountNumber: [{ required: true, message: '请选择收款账号', trigger: 'blur' }],
				filePayment: [{ required: true, message: '上传凭证', trigger: 'blur' }],
			},
			isdisabled: false,
			planData: {
				id: "",
				groupId: ''
			},
			groupList: [],
			// 遮罩层
			loading: true,
			// 选中数组
			ids: [],
			// 非单个禁用
			single: true,
			// 非多个禁用
			multiple: true,
			// 显示搜索条件
			showSearch: true,
			// 总条数
			total: 0,
			// 查询参数
			queryParams: {
				pageNum: 1,
				pageSize: 10,
				orderNumber: '',
				customerName: '',
				customerPhone: '',
				address: '',
				status: '',
				groupId: '',
				createUserId: '',
				filterCancel: 0,
				produce: '',
				billMonth: '',
				orderSource: '',
				priority: '',
				beginTime: '',
				endTime: '',
				finishTimeBegin: '',
				finishTimeEnd: '',
				deliveryTimeBegin: '',
				deliveryTimeEnd: '',


			},
			// 数据列表
			dataList: [],
			// 生产角色下所有用户列表
			scUserList: [],
			// 必选参数，上传的地址
			uploadAction: process.env.VUE_APP_BASE_API + '/common/upload',
			// 设置上传的请求头部
			uploadHeaders: {
				Authorization: 'Bearer ' + getToken()
			},
			// 上传的文件列表
			uploadImageList: [],
			editData: {},
			type: 0,
			glist: [],
			userList: [],
			amountSum1: 0,
			amountSum2: 0,
			amountSum3: 0,
			amountSum4: 0,
			amountSum5: 0,
			product_count_sum: 0,
			hjys:0,
			hjss:0,
			deliveryopen: false,
			deliveryFrom: {
				id: '',
				deliveryName: '',
				deliveryNumber: '',
				deliveryCode: '',
			},
			wuliuList: [],
			rules: {
				deliveryName: [{
					required: true,
					message: '请选择快递平台',
					trigger: 'blur'
				}],
				deliveryNumber: [{
					required: true,
					message: '请输入物流单号',
					trigger: 'blur'
				}],
			},
			shopen: false,
			shfrom: {
				orderId: '',
				problemType: '',
				problemDescribe: '',
				problemImg: ''
			},
			shrules: {
				problemType: [{
					required: true,
					message: '请选择问题类型',
					trigger: 'blur'
				}],
				problemDescribe: [{
					required: true,
					message: '请输入问题描述',
					trigger: 'blur'
				}],
				problemImg: [{
					required: true,
					message: '请上传售后文件',
					trigger: 'blur'
				}],
			},
			fileList: [],
			selectList: [],  //排产前选中的数据
			scheduopen: false,
			shengchanList: [],
			dialogFormVisible: false,
			shengchanform: {
				num: ''
			},
			shengchanrules: {
				num: [{
					required: true,
					message: '请输入产品数量',
					trigger: 'blur'
				}]
			},
			priceShow: false,
			priceForm: {
				id: '',
				amountCompensate: ''
			},
			priceFormles: {

			}
		}

	},
	created() {
		this.getDataList()
		this.getGroupList()
		this.getList()
		this.getUserList()
		postDeliveryList({}).then(res => {
			this.wuliuList = res.rows
		})
		//获取默认的产品数量 在参数设置里面拿
		this.getConfigKey("batch.product.default.count").then(response => {
			if (response.code == 200) {
				if (response.msg != '') {
					this.shengchanform.num = response.msg
				} else {
					this.shengchanform.num = '30'
				}
			}
		});
	},
	methods: {
		checkPermi,
		checkRole,
		//设置理赔金额
		setPrice(row) {
			this.priceForm.id = row.id
			this.priceForm.amountCompensate = row.amountCompensate
			this.priceShow = true
		},
		priceFormConfim() {
			setPricePost(this.priceForm).then(res => {
				if (res.code == 200) {
					this.$modal.msgSuccess("设置成功");
					this.priceShow = false
				}
			})
		},
		setDate() {
			let currentDate = new Date();
			let year = currentDate.getFullYear();
			let month = String(currentDate.getMonth() + 1).padStart(2, '0');
			let day = String(currentDate.getDate()).padStart(2, '0');
			this.payData.datePaymentStr = `${year}-${month}-${day}`
		},
		handleEyes() {
			getEcharts(this.queryParams).then(res => {
				let list1 = res.data.map(item => ({
					value: item.customer_count,
					name: item.customer_province,
					num: item.customer_ratio
				}))
				let list2 = res.data.map(item => ({
					value: item.order_count,
					name: item.customer_province,
					num: item.order_ratio
				}))
				console.log(list1, list2);
				this.planShow = true
				this.$nextTick(() => {
					const mychart = echarts.init(this.$refs.echartsZx1);
					// 绘制图表
					const option = {
						title: {
							text: '各省份客户数量',
							left: 'left'
						},
						tooltip: {
							trigger: 'item'
						},
						legend: {
							type: 'plain',
							data: list1.map(item => item.name),
							bottom: "0%",

						},
						label: {
							alignTo: 'edge',
							formatter: '{name|{b}}\n{time|{c} 人}',
							minMargin: 5,
							edgeDistance: 10,
							lineHeight: 15,
							rich: {
								time: {
									fontSize: 12,
									color: '#999'
								}
							}
						},
						series: [
							{
								name: '客户数量',
								type: 'pie',
								radius: '50%',
								data: list1,
								emphasis: {
									itemStyle: {
										shadowBlur: 10,
										shadowOffsetX: 0,
										shadowColor: 'rgba(0, 0, 0, 0.5)'
									}
								},
							},
							{
								name: '客户数量',
								type: 'pie',
								radius: '50%',
								data: list1,
								emphasis: {
									itemStyle: {
										shadowBlur: 10,
										shadowOffsetX: 0,
										shadowColor: 'rgba(0, 0, 0, 0.5)'
									}
								},
								label: {
									normal: {
										position: 'inside',
										show: true,
										formatter: '{d}%'
									}
								}

							},
						]
					}
					mychart.setOption(option);
					window.addEventListener('resize', function () {
						mychart.resize()
					})

					const mychart1 = echarts.init(this.$refs.echartsZx2);
					// 绘制图表
					const option1 = {
						title: {
							text: '各省份订单数量',
							left: 'left'
						},
						tooltip: {
							trigger: 'item'
						},
						legend: {
							type: 'plain',
							data: list2.map(item => item.name),
							bottom: "0%",
						},
						label: {
							alignTo: 'edge',
							formatter: '{name|{b}}\n{time|{c} 单}',
							minMargin: 5,
							edgeDistance: 10,
							lineHeight: 15,
							rich: {
								time: {
									fontSize: 12,
									color: '#999'
								}
							}
						},
						series: [
							{
								name: '订单数量',
								type: 'pie',
								radius: '50%',
								data: list2,
								emphasis: {
									itemStyle: {
										shadowBlur: 10,
										shadowOffsetX: 0,
										shadowColor: 'rgba(0, 0, 0, 0.5)'
									}
								}
							},
							{
								name: '订单数量',
								type: 'pie',
								radius: '50%',
								data: list2,
								emphasis: {
									itemStyle: {
										shadowBlur: 10,
										shadowOffsetX: 0,
										shadowColor: 'rgba(0, 0, 0, 0.5)'
									}
								},
								label: {
									normal: {
										position: 'inside',
										show: true,
										formatter: '{d}%'
									}
								}

							},
						]
					}
					mychart1.setOption(option1);
					window.addEventListener('resize', function () {
						mychart1.resize()
					})
				})
			})
			// 基于准备好的dom，初始化echarts实例
		},
		planCancel() {
			this.planShow = false
		},
		handlePaste(e) {
			let now = new Date().getTime()
			if (now - this.timeStep < 500) {
				this.$message.warning('粘贴速度太频繁！请稍后再试');
				return
			}
			this.timeStep = now
			var clipboardData = e.clipboardData; // IE
			if (!clipboardData) {
				//chrome
				clipboardData = e.originalEvent.clipboardData;
			}
			var items = '';
			items = (e.clipboardData || window.clipboardData).items;
			let file = null;
			if (!items || items.length === 0) {
				this.$message.error('当前浏览器不支持粘贴本地图片，请打开图片复制后再粘贴！');
				return;
			}
			// 搜索剪切板items
			for (let i = 0; i < items.length; i++) {
				// 限制上传文件类型
				if (items[i].type.indexOf('image') !== -1) {
					file = items[i].getAsFile();
					break;
				}
			}
			if (file) {
				this.$refs.productImage.handleStart(file); // 将粘贴过来的图片加入预上传队列
				this.$refs.productImage.submit(); // 提交图片上传队列
			} else {
				this.$message.error("粘贴内容非图片");
			}
		},
		handleExport() {
			this.$confirm('此操作将导出订单信息, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {

				exportOrder(this.queryParams).then(response => {
					const blob = new Blob([response], {
						type: 'text/plain;charset=utf-8'
					})
					const now = new Date(); // 获取当前时间
					const year = now.getFullYear(); // 年份
					const month = now.getMonth() + 1; // 月份，
					const date = now.getDate(); // 日期
					// 组合成字符串
					const formattedTime =
						`${year}-${month.toString().padStart(2, '0')}-${date.toString().padStart(2, '0')}`;
					let name = ''
					if (this.dateRange.length == 2) {
						name = `订单导出[${this.queryParams.beginTime}-${this.queryParams.endTime}].xlsx`
					} else {
						name = `订单导出-${formattedTime}-${now.getTime()}.xlsx`
					}
					saveAs(blob, name)
					// this.$download.saveAs(blob,'1.xlsx')
				});
			}).catch(() => {
				this.$message({
					type: 'info',
					message: '已取消'
				});
			});

			// this.download(
			//   '/orders/export',
			//   {
			//     ...this.queryParams,
			//   },
			//   `order_${new Date().getTime()}.xlsx`
			// )
		},
		//客服列表
		getUserList() {
			getUserListRole({
				codes: 'kefu',
			}).then((response) => {
				let list = response.data
				this.userList = list.map(item => {
					return {
						label: item.nickName,
						value: item.userId
					}
				})
				this.userList.unshift({
					label: '超级管理员',
					value: 1
				})

			})
		},


		handleProductImageRemove(response, file, fileList) {
			let as = file.map(item => item.response.url)
			this.$set(this.payData, 'filePayment', as)
		},
		// 上传图片
		handleUploadSuccess(response, file, fileList) {
			let as = fileList.map(item => item.response.url)
			this.$set(this.payData, 'filePayment', as)
		},
		timeChange(e) {
			console.log(e)
			if (e) {
				this.queryParams.beginTime = e[0]
				this.queryParams.endTime = e[1]
			} else {
				this.queryParams.beginTime = ''
				this.queryParams.endTime = ''
			}
		},
		timeChange1(e) {
			if (e) {
				this.queryParams.finishTimeBegin = e[0]
				this.queryParams.finishTimeEnd = e[1]
			} else {
				this.queryParams.finishTimeBegin = ''
				this.queryParams.finishTimeEnd = ''
			}
		},
		timeChange2(e) {
			if (e) {
				this.queryParams.deliveryTimeBegin = e[0]
				this.queryParams.deliveryTimeEnd = e[1]
			} else {
				this.queryParams.deliveryTimeBegin = ''
				this.queryParams.deliveryTimeEnd = ''
			}
		},
		getList() {
			getsslist().then(response => {
				let list = response.data;
				this.slist = list.map(item => {
					return {
						value: item.dictValue,
						label: item.dictLabel
					}
				})
			});
			return
		},
		getGroupList() {
			postUserGroupList({
				pageNum: 1,
				pageSize: 10000,
			}).then((response) => {
				let list = response.rows
				this.glist = list.map(item => {
					return {
						label: item.groupName,
						value: item.id
					}
				})
				response.rows.forEach((item) => {
					item.user1 = JSON.parse(item.step1)
					item.user2 = JSON.parse(item.step2)
					item.user3 = JSON.parse(item.step3)
					item.user4 = JSON.parse(item.step4)
					item.user5 = JSON.parse(item.step5)
					item.usersName =
						item.user1.userName + '、' + item.user2.userName + '、' + item.user3.userName +
						'、' + item.user4.userName + '、' + item.user5.userName
					item.userList = [item.user1, item.user2, item.user3, item.user4, item.user5]
				})
				this.groupList = response.rows
			})
		},
		//确认订单
		confirmDetail(data) {
			this.$confirm('此操作将确认订单, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				postOrdersConfirm({
					id: data.id
				}).then((response) => {
					if (response.code == 200) {
						this.$message({
							message: '订单已确认',
							type: 'success'
						});
						this.getDataList()
					}
				})

			}).catch(() => {
				// this.$message({
				// 	type: 'info',
				// 	message: '已取消'
				// });
			});
		},
		//取消订单
		handleCancel(data) {
			this.$confirm('此操作将取消订单, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				postOrdersCancel({
					id: data.id
				}).then((response) => {
					if (response.code == 200) {
						this.$message({
							message: '订单已取消',
							type: 'success'
						});
						this.getDataList()
					}
				})
			}).catch(() => {
				// this.$message({
				// 	type: 'info',
				// 	message: '已取消'
				// });
			});

		},
		//完成订单
		overDetail(data) {
			this.$confirm('此操作将完成订单, 是否继续?', '提示', {
				confirmButtonText: '确定',
				cancelButtonText: '取消',
				type: 'warning'
			}).then(() => {
				postOrdersFinish({
					id: data.id
				}).then((response) => {
					if (response.code == 200) {
						this.$message({
							message: '订单已完成',
							type: 'success'
						});
						this.getDataList()
					}
				})
			}).catch(() => {
				// this.$message({
				// 	type: 'info',
				// 	message: '已取消'
				// });
			});

		},
		/** 查询列表 */
		getDataList() {
			this.loading = true
			postOrdersList(this.queryParams).then((response) => {
				if (response.code == 200) {
					this.dataList = response.rows
					this.total = response.total
					this.loading = false
					postOrdersPaySum(this.queryParams).then((res) => {
						if (res.code == 200) {
							this.amountSum1 = res.data.amount_receipts_sum
							this.amountSum2 = res.data.amount_receivable_sum
							this.amountSum3 = res.data.amount_compensate_sum
							this.amountSum4 = res.data.amount_delivery_sum
							this.amountSum5 = res.data.amount_delivery_true_sum
							this.product_count_sum = res.data.product_count_sum
							this.hjys =  parseFloat(this.amountSum2+ this.amountSum4).toFixed(2)
							this.hjss =  parseFloat(this.amountSum1+ this.amountSum5).toFixed(2)
						} else {
							this.amountSum1 = 0
							this.amountSum2 = 0
							this.amountSum3 = 0
							this.amountSum4 = 0
							this.amountSum5 = 0
							this.product_count_sum = 0
						}
					})
				}

			})

		},
		/** 搜索按钮操作 */
		handleQuery() {
			this.queryParams.pageNum = 1
			this.getDataList()
		},
		/** 重置按钮操作 */
		resetQuery() {
			this.dateRange = []
			this.dateRange1 = []
			this.resetForm('queryForm')
			this.queryParams.orderNumber = ''
			this.queryParams.customerName = ''
			this.queryParams.customerPhone = ''
			this.queryParams.address = ''
			this.queryParams.status = ''
			this.queryParams.groupId = ''
			this.queryParams.createUserId = ''
			this.queryParams.produce = ''
			this.queryParams.billMonth = ''
			this.queryParams.orderSource = ''
			this.queryParams.priority = ''
			this.queryParams.beginTime = ''
			this.queryParams.endTime = ''
			this.queryParams.finishTimeBegin = ''
			this.queryParams.finishTimeEnd = ''
			this.queryParams.deliveryTimeBegin = ''
			this.queryParams.deliveryTimeEnd = ''
			this.handleQuery()
		},
		/** 多选框选中数据 */
		handleSelectionChange(selection) {
			this.selectList = selection
			this.ids = selection.map((item) => item.id)
			this.single = !selection.length
			this.multiple = !selection.length
			this.editData = selection
		},
		payCancel() {
			this.payShow = false
			this.deliveryopen = false
			this.shopen = false
			this.scheduopen = false
			this.deliveryFrom = {}
			this.payData = {}
			this.uploadImageList = []
			this.shfrom = {}
		},
		pricechange(e) {
			console.log(e);
			let as = this.packageList.filter(item => {
				return item.id == e
			})
			let a = Math.round(this.paydataInfos.amountReceivable * (as[0].ratio / 100))
			this.payData.dk = Math.min(as[0].amountSubRatio, a)
			this.payData.yf = Math.round(this.paydataInfos.amountReceivable - this.payData.dk)
			// if (as[0].amountSubRatio >= a) {
			// 	this.payData.dk = a
			// 	let b = Math.round(this.paydataInfos.amountReceivable - this.payData.dk)
			// 	this.payData.yf = b
			// 	return
			// }
			// if (as[0].amountSubRatio < a) {
			// 	this.payData.dk = as[0].amountSubRatio
			// 	let b = Math.round(this.paydataInfos.amountReceivable - this.payData.dk)
			// 	this.payData.yf = b
			// 	return
			// }
		},
		addPay(data) {
			this.payData = {
				orderId: '',
				recordType: '',
				typePayment: '',
				packageId: '',
				amountPayment: '',
				filePayment: '',
				datePaymentStr: '',
				accountTypeName: '',
				accountNumber: '',
				remark: '',
			}
			this.paydataInfos = data
			this.payData.orderId = data.id
			this.setDate()
			this.payShow = true
		},
		paychange(e) {
			let data = {
				orderId: this.paydataInfos.id,
				customerId: this.paydataInfos.customerId
			}
			this.$set(this.payData, 'amountPayment', 0)
			if (e == '订单金额') {
				getCheckPay(data).then(res => {
					this.packageList = res.data.packageList
					if (res.data.typePayment == '01') {
						this.$set(this.payData, 'typePayment', res.data.typePayment)
						let a = this.paydataInfos.amountReceivable - this.paydataInfos.amountReceipts
						this.$set(this.payData, 'amountPayment', parseFloat(a).toFixed(2))
						this.isdisabled = true
					} else if (res.data.typePayment == '02') {
						this.$set(this.payData, 'typePayment', res.data.typePayment)
						this.payData.amountPayment = this.paydataInfos.amountReceivable
						this.isdisabled = true
					} else {
						this.isdisabled = false
						this.payData.amountPayment = this.paydataInfos.amountReceivable
					}
				})
			} else {
				this.$set(this.payData, 'typePayment', '01')
				let a = this.paydataInfos.amountDelivery - this.paydataInfos.amountDeliveryTrue
				this.$set(this.payData, 'amountPayment', parseFloat(a).toFixed(2))

			}
		},
		typePaymentChange(e) {
			if (e == '02') {
				this.$set(this.payData, 'amountPayment', this.paydataInfos.amountReceivable)
			} else {
				let a = this.paydataInfos.amountReceivable - this.paydataInfos.amountReceipts
				this.payData.amountPayment = parseFloat(a).toFixed(2)

			}
		},
		paychangzhangh(e) {
			getzhanghList({ pageNum: 1, pageSize: 1000, accountType: e }).then(res => {
				this.zhanghlist = res.rows
			})
		},
		payConfirm: function () {
			this.$refs["payFormRef"].validate((valid) => {
				if (valid) {
					this.payData.filePayment = this.payData.filePayment.toString()
					postOrdersPayAdd(this.payData).then(res => {
						if (res.code == 200) {
							this.$modal.msgSuccess("收款已申请");
							this.payCancel()
							this.getDataList()
						}
					})
				}
			});
		},
		downexportOrder(row) {
			console.log(row);
			this.download(
				"orders/print/order",
				{ id: row.id },
				`订货确认单.xlsx`
			);
		},
		/** 新增按钮操作 */
		handleAdd() {
			this.$router.push('/order/add')
		},
		/** 订单详情 */
		handleDetail(row) {
			this.$router.push('/order/detail/' + row.id)
		},
		//订单排产 新增
		handleOrder() {
			const isActve = this.selectList.every((item) => {
				return item.status == '20'
			})
			if (isActve) {
				scheduWarn({ ids: this.ids }).then(res => {
					if (res.code == 200) {
						if (res.data.result) {
							let arr = res.data.warnList.map((item) => item.orderId)
							let uniqueArr = [...new Set(arr)];
							this.$modal.confirm('订单ID为"' + uniqueArr + '"的数据项中有产品低于预警价格了！！！')
								.then(() => {
									scheduList({ ids: this.ids }).then(res => {
										if (res.code == 200) {
											this.shengchanList = res.data
											this.scheduopen = true
										}
									})
								})
								.catch(() => {
									this.$message({
										type: 'info',
										message: '已取消'
									});
								})
						} else {
							scheduList({ ids: this.ids }).then(res => {
								if (res.code == 200) {
									this.shengchanList = res.data
									this.scheduopen = true
								}
							})
						}

					}
				})
			} else {
				this.$message({
					type: 'warning',
					message: '有不符合排产条件的订单，请重新选择!!'
				});
			}
		},
		//确认排产
		paichanConfirm() {
			let ids = this.shengchanList.map((item) => item.id)
			scheduYes({ ids }).then(res => {
				if (res.code == 200) {
					this.$router.push('/batch/list')
				}
			})
		},
		shengchanConfim: function () {
			this.$refs["shengchanform"].validate((valid) => {
				if (valid) {
					scheduList({ ids: this.ids, num: this.shengchanform.num }).then(res => {
						if (res.code == 200) {
							this.dialogFormVisible = false
							this.shengchanList = res.data
						}
					})
				}
			});
		},
		/** 修改按钮操作 */
		handleUpdate(row) {
			let rowData
			if (row.id) {
				rowData = row
			} else {
				rowData = this.dataList.find((item) => item.id === this.ids[0])
			}
			this.$router.push('/order/edit/' + rowData.id)
		},
		/** 删除按钮操作 */
		handleDel(row) {
			const id = row.id ? row.id : this.ids
			this.$modal
				.confirm('是否确认删除客户ID为"' + id + '"的数据项？')
				.then(function () {
					return postOrdersRemove({
						id
					})
				})
				.then(() => {
					this.getDataList()
					this.$modal.msgSuccess('删除成功')
				})
				.catch(() => { })
		},
		//修改颜色
		tableRowClassName({ row, column, rowIndex, columnIndex }) {
			//实收金额
			// 0+0 168+10
			let ssprice = row.amountReceipts + row.amountDeliveryTrue
			//应收金额
			let ysprice = row.amountReceivable + row.amountDelivery
			let x = ssprice - ysprice
			// -960

			if (row.billMonth != '' && x > 2 && columnIndex == 2) {
				return { color: 'green', fontWeight: 'bold' }
			} else if (row.billMonth != '' && Math.abs(x) <= 2 && columnIndex == 2) {
				return ''
			} else if (x < -2 && columnIndex == 2) {
				if (row.billMonth == '是' && columnIndex == 2) {
					return { color: 'blue', fontWeight: 'bold' }
				} else if (row.billMonth == '否' && columnIndex == 2) {
					return { color: 'red', fontWeight: 'bold' }
				}
			}
		},
		pestChange(e) {
			this.deliveryFrom.deliveryName = e.deliveryName
			this.deliveryFrom.deliveryCode = e.deliveryCode
		},
		//修改物流
		editDelivery(row) {
			this.deliveryFrom = row
			this.deliveryopen = true
		},
		deliveryConfirm: function () {
			this.$refs["deliveryFrom"].validate((valid) => {
				if (valid) {
					postDditDelivery(this.deliveryFrom).then(res => {
						this.$modal.msgSuccess("修改成功");
						this.deliveryopen = false
						this.getDataList();
					})
				}
			});
		},
		shconfirm(row) {
			this.shfrom = {}
			this.shfrom.orderId = row.id
			this.fileList = []
			this.shopen = true
		},
		shyConfirm: function () {
			this.shfrom.problemImg = this.shfrom.problemImg.toString()
			this.$refs["shfrom"].validate((valid) => {
				if (valid) {
					postAfter(this.shfrom).then(res => {
						this.$modal.msgSuccess("已提交");
						this.shopen = false
						this.getDataList();
					})
				}
			});
		},
		handleProductImageRemove1(response, file, fileList) {
			this.shfrom.problemImg = file.map(item => item.response.url)
		},
		// 上传图片
		handleUploadSuccess1(response, file, fileList) {
			this.shfrom.problemImg = fileList.map(item => item.response.url)
		},
		paychang(e) {
			this.formpay.accountNumber = ''
			getzhanghList({ pageNum: 1, pageSize: 1000, accountType: e }).then(res => {
				this.zhanghlist = res.rows
			})
		},

	},
}
</script>

<style lang="scss">
.el-table .warning-row {
	background: blue;
}

.el-table .success-row {
	background: red;
}

.el-table .warning-row {
	background: green;
}

.uopen .el-dialog__body {
	padding: 10px 20px 20px;
}
</style>